#! /bin/sh
#
# transmission
#
# chkconfig: S 100 2
#

PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/bin
DAEMON=/usr/bin/transmission-daemon
DESC="Torrent client"
NAME=transmission
CONFIGDIR="/etc/transmission"

[ -x $DAEMON ] || exit 1


case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start \
		--exec $DAEMON -- -g $CONFIGDIR
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --oknodo --exec $DAEMON
	echo "$NAME."
	;;
  reload|force-reload)
	echo "Reloading $DESC configuration files."
	start-stop-daemon --stop --signal 1 --exec $DAEMON
	;;
  restart)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --oknodo --exec $DAEMON
	echo "done."
	sleep 5
	start-stop-daemon --start  \
		--exec $DAEMON -- -g $CONFIGDIR
	echo "$NAME."
        ;;
  enable)
	initdconfig --add transmission
	;;
  disable)
	initdconfig --del transmission
	;;
  *)
	echo "Usage: $0 {start|stop|restart|reload|force-reload|enable|disable}" >&2
	exit 1
	;;
esac

exit 0
